package cn.wolfcode.book.service.impl;
import cn.wolfcode.book.entity.Book;
import cn.wolfcode.book.service.BookService;
import cn.wolfcode.book.service.IEmployeeService;
import cn.wolfcode.entity.PageResult;
import cn.wolfcode.entity.QueryObject;
import org.junit.Test;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-10-28 12:47
 */
public class BookServiceImplTest {
    BookService bookService=new BookServiceImpl();
    private final IEmployeeService employeeService=new EmployeeServiceImpl();

    @Test
    public void add() {
        employeeService.add();

    }
    @Test
    public void delById() {
    }

    @Test
    public void selOneById() {
    }

    @Test
    public void selAll() {
        List<Book> books = bookService.selAll();
        books.forEach(System.out::println);
    }

    @Test
    public void save() {
        Book book=new Book();
        //todo id参数  添加和修改
//        book.setId(12L);
        book.setBname("追风筝的人");
        book.setAuthor("卡勒德·胡赛尼(Khaled Hosseini)");
        book.setSalePrice(new BigDecimal("632"));
        book.setCostPrice(new BigDecimal("178"));
//        book.setClassify(14L);
        bookService.save(book);

    }
    @Test
    public void query() {
        QueryObject queryObject = new QueryObject(3, 5);
        PageResult<Book> query = bookService.query(queryObject);
        System.out.println("当前页"+query.getCurrentPage());
        System.out.println("每页显示条数:"+query.getPageSize());
        System.out.println("当前页数据:"+query.getData());
        System.out.println("总页数:"+query.getTotalPage());
        System.out.println("总条数:"+query.getTotalCount());
        System.out.println("上一页："+query.getPrevPage());
        System.out.println("下一页："+query.getNextPage());
    }
    @Test
    public void T(){
        BookServiceImpl bookService=new BookServiceImpl();
        bookService.T(new QueryObject(2,3));
    }
}